package procedure;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 工序节点
 * 前置条件:1.结构规则 2.工序在一个产线中是唯一的 3.不能新增外部的
 */
public class Node {

    private Integer id;

    private String name;

    //节点类型 1-默认 0-空点(用来开头,不参与计算)
    private Integer type = 1;

    //识别工序内容是否一样 2022/03/23 - 工序id修改
    private WorkId workId;
//    private String virtualId;

    //周产能
    private Integer produce;

    //临时产能 合并计算时使用
    private Integer tempProduce = 0;

    //合格率 例:90% 实际保存 9000
    private Integer qualifiedPercent;

    //瓶颈节点
    private List<Node> bottleneck = new ArrayList<>();

    //前置节点
    private List<Node> preList = new ArrayList<>();

    //后置节点
    private List<Node> afterList = new ArrayList<>();


    Node(int id, String name, int produce, int qualifiedPercent) {
        this.id = id;
        this.name = name;
        this.produce = produce;
        this.qualifiedPercent = qualifiedPercent;
    }

    @Override
    public String toString() {
        return "Node{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", produce=" + produce +
                ", qualify=" + qualifiedPercent +
                ", bn=" + bottleneck.stream().map(Node::getName).collect(Collectors.joining(",")) +
                ", " + (null == workId ? "workId = null" : workId.toString()) +
                '}';
    }

    public String show() {
        return "[" + this.name + "]";
    }

    public void addPre(Node pre) {
        this.preList.add(pre);
    }

    public void addAfter(Node after) {
        this.afterList.add(after);
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public WorkId getWorkId() {
        return workId;
    }

    public void setWorkId(WorkId workId) {
        this.workId = workId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public List<Node> getPreList() {
        return preList;
    }

    public void setPreList(List<Node> preList) {
        this.preList = preList;
    }

    public List<Node> getAfterList() {
        return afterList;
    }

    public void setAfterList(List<Node> afterList) {
        this.afterList = afterList;
    }

    public Integer getProduce() {
        return produce;
    }

    public void setProduce(Integer produce) {
        this.produce = produce;
    }

    public Integer getTempProduce() {
        return tempProduce;
    }

    public void setTempProduce(Integer tempProduce) {
        this.tempProduce = tempProduce;
    }

    public Integer getQualifiedPercent() {
        return qualifiedPercent;
    }

    public void setQualifiedPercent(Integer qualifiedPercent) {
        this.qualifiedPercent = qualifiedPercent;
    }

    public List<Node> getBottleneck() {
        return bottleneck;
    }

}
